var express = require('express')
var router = express.Router()
var jwt = require('jwt-simple')
var auth = require('../../middleware/auth')

/*
 * users token  create  2017.7.10 
 */
 
router.get('/',auth.basic(),(req, res)=>{
    res.status(200).json({
        type: 'JWT',
        token: jwt.encode({ username:req.user.username,id:req.user.id,password:req.user.password}, 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsy5lLitR93SFagVQTgQABjrNUMH16BmodAWsVJjEoS0yWBqmg/qJoYQEOn93QHEAPFwFgSmBH+K3amGvcXdCneVz1wyiNGBPT4lusoo0SS2vxnGNmD3DXcMQvB4EJiC/rTgyBaelu4ZE/2eVSMiOXtjIENHMw6JlI4Ml+k+PStlbkNs1WbL4FtGiobSX5gFjvAhrtESLRRsUVwWF16UhOgO9O2c9QdguwtStThhpPJmuzw12hvKMLGeafSdW0VPqBm8FFrhMk6BlDdCtAnQAWR1agEx2eYXri2e3J68NlEtYKIFEx9DjZog3ADQHz7xT0uk91BgpbmX5brnLgA6ZsQIDAQAB'),
        user:req.user
      })
})

module.exports = router;